﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Acms.Bll;
using Telerik.Web.UI;

public partial class Topics_Groups : BaseTopicPage, IPostBackEventHandler
{
    protected void Page_Load(object sender, EventArgs e)
    {
        winInsert.OpenerElementID = lnkAdd.ClientID;
        ClientScript.RegisterStartupScript(this.GetType(), "lnkRefreshId", string.Format("lnkRefreshId = \"{0}\";", lnkRefresh.UniqueID), true);
    }

    public override Acms.Bll.Role.Roles[] AllowedRoles
    {
        get { return new Acms.Bll.Role.Roles[] { Acms.Bll.Role.Roles.Developer }; }
    }

    protected void dsGroups_SelectData(object sender, Acms.DataControls.SelectEventArgs<Acms.Bll.TopicGroup> e)
    {

        e.SetData(TopicGroup.GetAllBySiteId(AcmsContext.SiteId));
    }

    protected void dsGroups_UpdatingData(object sender, Acms.DataControls.UpdatingDataEventArgs<TopicGroup> e)
    {
        if (e.Action == Acms.DataControls.UpdateAction.Insert)
        {
            e.Item.SiteId = AcmsContext.SiteId;
        }
    }
    protected void gridRoles_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {

    }
    protected void gridRoles_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {

    }

    #region IPostBackEventHandler Members

    public void RaisePostBackEvent(string eventArgument)
    {
        if (eventArgument == "Refresh")
        {
            gvGroups.Rebind();
        }
    }

    #endregion

    protected void lnkRefresh_Click(object sender, EventArgs e)
    {
        gvGroups.Rebind();
    }
    protected void lnkAdd_Click(object sender, EventArgs e)
    {
        winInsert.VisibleOnPageLoad = true;
    }
}
